package com.spark.colliery.module.mine.fragment

import android.os.Bundle
import android.text.TextUtils
import android.view.View
import com.spark.colliery.R
import com.spark.common.BaseFragment
import com.spark.common.ext.toast
import com.spark.common.widget.ConfirmAlert
import kotlinx.android.synthetic.main.fragment_profile_change_phone.*

/**
 * Change the phone number
 */
class ProfileChangePhoneFragment : BaseFragment() {
    companion object {
        fun newInstance(): ProfileChangePhoneFragment {
            val args = Bundle()
            val fragment = ProfileChangePhoneFragment()
            fragment.arguments = args
            return fragment
        }
    }

    override fun contentResId(): Int {
        return R.layout.fragment_profile_change_phone
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        tv_title.text = "修改手机"
        iv_back.setOnClickListener { pop() }

        btn_save.setOnClickListener {
            val newPhone = et_new_phone.text.toString().trim { it <= ' ' }

            if (TextUtils.isEmpty(newPhone)) {
                ConfirmAlert(activity).show(activity?.resources?.getString(R.string.hint_change_phone)
                        ?: "")
            } else {
                toast("保存成功")
                pop()
            }
        }
    }


}
